package com.cedric.yixianpai.game.Status;

import com.cedric.yixianpai.game.Constants.CardType;

/**
 * 游戏进程，使用duelBuff
 */
public class DuelBuff {
    private int shield;//护盾
    private int recovery;//恢复
    private int spiritualEnergy;//灵气
    private int swordIntent;//剑意
    private int ignoreDefense = 0;//无视防御
    private boolean returnIntent = false;//返还剑意
    private CardType lastUseType = CardType.NOTHING;//上一张使用的卡牌类型
    private int Yun_Times = 0;//云剑使用次数
    private int Yun_Consecutive = 0;//云剑连续使用次数
    private int Yun_Cure = 0;//使用云剑时加血
    private int Kuang_Times = 0;//狂剑使用次数
    private int nextShield = 0;//下回合加防
    private int attackAdd = 0;//加攻
    private int JulingXF = 0;//(聚灵心法)每有两层此状态，回合开始加1灵气
    private int addJuLingXF = 0;//每回合增加上述状态
    private int BaiNiaoLJ = 0;//(百鸟灵剑决)灵剑减少灵气
    private int shieldKeep = 0;//护盾不减少轮数
    private int Kuang_Vampire = 0;//狂剑吸血幅度 x%
    private boolean LHJZ = false;//连环剑阵
    private int JZIndex =-1;//上一张剑阵的索引

    public DuelBuff() {
        this.shield = 0;
        this.recovery = 0;
        this.spiritualEnergy = 0;
        this.swordIntent = 0;
    }

    public DuelBuff(int shield, int recovery, int spiritualEnergy, int swordIntent, int sharpNess) {
        this.shield = shield;
        this.recovery = recovery;
        this.spiritualEnergy = spiritualEnergy;
        this.swordIntent = swordIntent;
    }


    public int getShield() {
        return shield;
    }

    public void setShield(int shield) {
        this.shield = shield;
    }

    public int getRecovery() {
        return recovery;
    }

    public void setRecovery(int recovery) {
        this.recovery = recovery;
    }

    public int getSpiritualEnergy() {
        return spiritualEnergy;
    }

    public void clearSpiritualEnergy() {
        this.spiritualEnergy = 0;
    }

    public void addSpiritualEnergy(int add) {
        this.spiritualEnergy += add;
//        System.out.println("灵气增加" + add);
    }

    public void decSpiritualEnergy(int dec) {
        this.spiritualEnergy -= dec;
//        System.out.println("灵气减少" + dec);
    }

    public int getSwordIntent() {
        return swordIntent;
    }

    public void setSwordIntent(int swordIntent) {
        this.swordIntent = swordIntent;
    }

    public void clearSwordIntent() {
        this.swordIntent = 0;
    }

    public void BeforeTurn() {
        //护盾衰减
        if (this.shield > 0) {
            if (this.shieldKeep > 0) {
//                System.out.println("本轮护盾不减半");
                this.shieldKeep -= 1;
            } else {
//                System.out.println("次轮护盾锐减为一半：" + this.shield + "->" + this.shield / 2);
                this.shield /= 2;
            }
        }
        //下回合加防
        if (this.nextShield > 0) {
            this.shield += this.nextShield;
            this.clearNextShield();
        }
        //每回合加灵气
        if (this.addJuLingXF > 0) {
            this.addJulingXinFa(this.addJuLingXF);
        }
        if (this.JulingXF >= 2) {
            int addSE = this.JulingXF / 2;
            this.addSpiritualEnergy(addSE);
            this.JulingXF -= 2 * addSE;
        }
    }

    public void addShield(int add) {
        this.shield += add;
//        System.out.println("护盾增加" + add);
    }

    public void decShield(int dec) {
        this.shield -= dec;
    }

    public void addSwordIntent(int add) {
        this.swordIntent += add;
//        System.out.println("剑意增加" + add);
    }

    public int getIgnoreDefense() {
        return ignoreDefense;
    }

    public void setIgnoreDefense(int ignoreDefense) {
        this.ignoreDefense = ignoreDefense;
    }

    /**
     * 添加n层无视防御
     */
    public void addIgnoreDefense(int n) {
        this.ignoreDefense += n;
    }

    public void decIgnoreDefense() {
        this.ignoreDefense -= 1;
    }

    public boolean isReturnIntent() {
        return returnIntent;
    }

    public void setReturnIntent(boolean returnIntent) {
        this.returnIntent = returnIntent;
    }

    public int getYun_Times() {
        return Yun_Times;
    }

    public void setYun_Times(int yun_Times) {
        Yun_Times = yun_Times;
    }

    public CardType getLastUseType() {
        return lastUseType;
    }

    /**
     * 记录卡牌类型，增加相应类型卡牌使用次数
     */
    public void recordLastType(CardType lastUseType) {
        this.lastUseType = lastUseType;
        if (lastUseType == CardType.YUN) {
            this.Yun_Times += 1;
        } else if (lastUseType == CardType.KUANG) {
            this.Kuang_Times += 1;
        }
    }

    public int getKuang_Times() {
        return Kuang_Times;
    }

    public void setKuang_Times(int kuang_Times) {
        Kuang_Times = kuang_Times;
    }

    public int getYun_Cure() {
        return Yun_Cure;
    }

    public void addYun_Cure(int yun_Cure) {
        Yun_Cure += yun_Cure;
    }

    public int getYun_Consecutive() {
        return Yun_Consecutive;
    }

    public void addYun_Consecutive() {
        Yun_Consecutive += 1;
    }

    public void clearYun_Consecutive() {
        Yun_Consecutive = 0;
    }

    public int getNextShield() {
        return nextShield;
    }

    public void addNextShield(int nextShield) {
        this.nextShield += nextShield;
    }

    public void clearNextShield() {
        this.nextShield = 0;
    }

    public int getAttackAdd() {
        return attackAdd;
    }

    public void addAttackAdd(int add) {
        this.attackAdd += add;
    }

    public void addJulingXinFa(int julingXinFa) {
        this.JulingXF += julingXinFa;
    }

    public void addAddJuLingXF(int add) {
        this.addJuLingXF += add;
    }

    public void addBaiNiaoLingJianJue(int lingDecSE) {
        BaiNiaoLJ += lingDecSE;
    }

    public int getBaiNiaoLJ() {
        return this.BaiNiaoLJ;
    }

    public void clearBaiNiaoLingJianJue() {
        this.BaiNiaoLJ = 0;
    }

    public int getShieldKeep() {
        return shieldKeep;
    }

    public void addShieldKeep(int t) {
        shieldKeep += t;
    }

    public int getKuang_Vampire() {
        return Kuang_Vampire;
    }

    public void addKuang_Vampire(int kuang_Vampire) {
        Kuang_Vampire += kuang_Vampire;
    }

    public int getJZIndex() {
        return JZIndex;
    }

    public void setJZIndex(int JZIndex) {
        this.JZIndex = JZIndex;
    }

    public boolean isLHJZ() {
        return LHJZ;
    }

    public void setLHJZ() {
        this.LHJZ = true;
    }

    public void resetLHJZ(){
        this.LHJZ =false;
    }
}
